package com.example.mobile2021606129ly0330;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity_cheng extends AppCompatActivity {

    private EditText edChe;
    private Button butCheRes;
    private TextView textCheRes;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_cheng);
        initView();

        butCheRes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int a= Integer.parseInt(edChe.getText().toString());

                if (a<60) {
                    textCheRes.setText('E');
                    if (a <= 69 && a >= 60) {
                        textCheRes.setText('D');
                        if (a <= 79 && a >= 70) {
                            textCheRes.setText('C');
                            if (a <= 89 && a >= 80) {
                                textCheRes.setText('B');
                                if (a < 100 && a >= 90) {
                                    textCheRes.setText('B');
                                }
                            } else {
                                textCheRes.setText("请输入100以内的数字");
                            }
                        }
                    }
                }
            }
        });
    }




    private void initView() {
        edChe = (EditText) findViewById(R.id.ed_che);
        butCheRes = (Button) findViewById(R.id.but_che_res);
        textCheRes = (TextView) findViewById(R.id.text_che_res);
    }
}